#! /usr/bin/env python3
# coding = uft-8
<<<<<<< HEAD
from pprint import pprint
import re
class Solution(object):
    def isMatch(self, s, p):
        """
        :type s: str
        :type p: str
        :rtype: bool
        """
        sl, pl = len(s), len(p)
        A = [[False for i in range(pl + 1)] for i in range(sl + 1)]
        A[0][0] = True

        for i in range(1, sl + 1):
            A[i][0] = False

        for j in range(1, pl + 1):
            A[0][j] = j > 1 and p[j - 1] == '*' and A[0][j - 2] is True

        for j in range(1, pl + 1):
            for i in range(1, sl + 1):
                pprint("s {} i= {}".format(s[0:i], i))
                pprint("p {} j = {}".format(p[0:j], j))
                #pprint(A)
                if p[j - 1] == s[i - 1] or p[j - 1] == '.':
                    A[i][j] = A[i-1][j-1]
                elif p[j - 1] == '*':
                    if p[j - 2] == '.' or p[j - 2] == s[i - 1]:
                        A[i][j] = A[i - 1][j] or A[i - 1][j - 2] or A[i][j - 2]
                    else:
                        A[i][j] = A[i][j - 2]
                else:
                    A[i][j] = False
                print("result = {}".format(A[i][j]))
                _tmp  = re.fullmatch(p[0:j], s[0:i])
                __tmp = False if _tmp is None else True
                if __tmp is not A[i][j]:
                    print("------------")
                    print(p[0:j], s[0:i])
                    #pprint(A)
                    return
        return A[sl][pl]

s = Solution()
print(s.isMatch("aasdfasdfasdfasdfas",
"aasdf.*asdf.*asdf.*asdf.*s"))

=======


class Solution(object):
    @staticmethod
    def rm_common_char(s):
        if '.' in s:
            s.clear()
            s.append('.')
        else:
            s.clear()

    def isMatch(self, s, p):
        sl, pl = len(s), len(p)
        a = [[0 for x in range(sl) + 1] for y in range(pl) + 1]

        for i in range(sl):
            a[i][0] = 0
        for i in range(pl):
            a[0][i] = 0
        a[0][0] = 1

        alt = []
        for j in range(1, pl + 1):
            for i in range(1, sl + 1):
                c = p[j]
                if c not in ['.', '*']:
                    a[i][j] = a[i - 1][j - 1]
        return a[sl][pl]

s = Solution()
print(s.isMatch("aab", "c*a*b"))
>>>>>>> 398cc8ef70902e6bbb366bdb76589a8a404d804b
